/*
 * @Author: malgee
 * @Date: 2025-04-23 09:52:59
 * @LastEditors: maling
 * @LastEditTime: 2025-04-23 10:18:29
 * @FilePath: /vue3-ts-cms/src/utils/cache.ts
 * @Description: 
 * 
 */
class LocalCache {
  
  set(key: string, value: any) {
    if (!key) return
    window.localStorage.setItem(key, JSON.stringify(value))
  }

  get(key: string) {
    if (!key) return
    const value = window.localStorage.getItem(key)
    if (!value) return
    return JSON.parse(value)
  }

  remove(key: string) {
    if (!key) return
    window.localStorage.removeItem(key)
  }

  clear() {
    window.localStorage.clear()
  }
}

export default new LocalCache()
